import { applyMiddleware, createStore } from "redux";
import thunk from "redux-thunk";
const reducer = function (state = {
    page: 1,
    list: [],
    loading: false
}, action) {
    switch (action.type) {
        case "loading":
            return {
                ...state,
                loading: true
            }
        case "update":
            return {
                ...state,
                list: action.list,
                loading: false
            }
        case "prev":
            return {
                ...state,
                page: state.page > 1 ? state.page - 1 : state.page

            }
        case "next":
            return {
                ...state,
                page: state.page + 1

            }
        default:
            return state
    }
};
export default createStore(reducer, applyMiddleware(thunk));